Setup

To setup dev environment, for using this crash course and also for doing real world work, you need to:

  • install pyenv which manages Python environments for you. you can also use anaconda, etc. -- YMMV.
  • install pyenv-virtualenv which setups virtualenv for your projects and have them isolated from one another.
  • remember to add the initing commands of pyenv in your shell profile, e.g. ~/.zshrc or ~/.bash_profile
  • use pyenv to install a Python version: the current suggestions are 2.7.11 and 3.5.1 - I personally recommend Python 3 because it is mature enough and also the future - but some libraries do not work in py3 - so a better way is to install both and have them managed by pyenv. this course will is written in py3.
  • use pip to install jupyter and notebook

Once you have everything setup, you can start the notebook using:

jupyter notebook

and your browser will be open, the notebook server will serve the content in its current directory, i.e. you can navigate to a directory where you want to view from notebook and use that command more easily.

a word about environments and pip

It is a very good habit to have your dev and app environment explicitly kept, version controlled, and re-producible. The commands that come handy are: pip freeze > requirements.txt and pip install -r requirements.txt. Whenever possible, setup git version control for your python project, use pip freeze to capture dependency list, so that others can quickly reproduce the deps by using the requirements.txt file.

N.B. this idea is not python specific, think about the package.json for node and pom.xml for Java

setting up a SQL database

Assuming you are on Mac, you can use brew install sqlite3 to install SQLite. It is a very simple tool that can give you SQL interface while not requiring you to setup a server and handle with databases, users, admins, etc. You can use SQLite in memory mode, or in most cases open up a database file for storing data for a database - in which you can create tables, views, primary keys, foreign keys, etc. Or if you are crazy enough you can have it setup as HA a distributed system using Raft.

Once you have it installed, you can start it:

sqlite3

in in memory mode or in most cases start it with a file path:

sqlite3 ~/path/to/my/work/dir/database_file.db

so that your data will be read from, and saved back to the database file.